package com.lzj.weather01;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * "id","province","city","adcode","weather","temperature","winddirection","windpower","humidity","reporttime","create_time"
 */
public class Weather01Util {

    public static void main(String[] args) throws ParseException {

        String str = "\"101252\",\"北京\",\"东城区\",\"110101\",\"晴\",\"18\",\"北\",\"≤3\",\"36\",\"18/10/2020 18:31:09\",\"18/10/2020 19:00:01\"";

        //替换掉特殊字符 101252,北京,东城区,110101,晴,18,北,≤3,36,18/10/2020 18:31:09,18/10/2020 19:00:01
        str = str.replaceAll("\"", "");
        //切分
        String[] datas = str.split(",");
        if (datas != null && datas.length == 11) {
            //获取数据
            String province = datas[1];
            String city = datas[2];
            String adcode = datas[3];
            String temperature = datas[5];
            String reporttime = datas[9];
            System.out.println("Weather01Util.main[" + adcode + "][" + temperature + "][" + reporttime + "]");
            //转换数据格式
            Date date = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").parse(reporttime);
            //打印年月日
            System.out.println(adcode + ":" + new SimpleDateFormat("yyyyMMdd").format(date));

        }

    }
}
